<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第 12 题</title>
    <script type="text/javascript">
        /*
            12、数组排序；
                [3,4,1,2,6,5] => [1,2,3,4,5,6]
        */

        // 创建数组
        var oArr = [3, 4, 1, 2, 6, 5];

        // 创建数组 => 存储
        var oArr1 = [];

        // 遍历次数
        for (var i = 0; i <= oArr.length; i++) {
            // 每次遍历后揪出最小的那一项，放到新数组的最后一位并删除原数组的该值。
            for (var a = 0; a <= oArr.length; a++) {
                oArr1.push(parseInt(oArr.splice(oArr.indexOf(Math.min(...oArr)), 1).join()));
            }
        }

        // 将值赋给原数组 oArr
        oArr = oArr1;

        console.log(oArr);
    </script>
</head>

<body>

</body>

</html>